package calorie.com.calorie.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;

import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.request.CancelOrderRequest;
import calorie.com.calorie.request.GoodsOrderRequest;
import calorie.com.calorie.response.CancelOrderResponce;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by chenxi on 2019/4/11.
 */

public class CancelOrderContact {
    public static class CancelOrderPresent extends BasePresent<ICancelOrderView> {
        public void cancelOrders(final Context context, String orderId, Integer userId,String dealPassword){
            ApiService service = ServiceGenerator.createService(ApiService.class);
            CancelOrderRequest request = new CancelOrderRequest(orderId,userId,dealPassword);
            service.cancelOrders(request).enqueue(new NetCallBack<CancelOrderResponce>() {
                @Override
                public void onSuccess(Call<CancelOrderResponce> call, Response<CancelOrderResponce> response) {
                    if(getView()!= null){
                        getView().getCancelOrderResult(response);
                    }
                }

                @Override
                public void onFailed() {

                }
            });
        }
    }

    public interface ICancelOrderView extends IBaseView {
        void getCancelOrderResult(Response<CancelOrderResponce> response);
    }
}
